<?php
// $Id$

/**
 * @file
 * 
 */

/**
 * Provides World of Warcraft constants and a few useful functions for using the
 * data. This class should not be instantiated.
 */
class WarcraftPlayer {
  const CLASS_WARRIOR = 1;
  const CLASS_PALADIN = 2;
  const CLASS_HUNTER  = 3;
  const CLASS_ROGUE   = 4;
  const CLASS_PRIEST  = 5;
  const CLASS_DEATHKNIGHT = 6;
  const CLASS_SHAMAN  = 7;
  const CLASS_MAGE    = 8;
  const CLASS_WARLOCK = 9;
  const CLASS_DRUID   = 11;
  
  const FACTION_ALLIANCE = 0;
  const FACTION_HORDE    = 1;
  
  const GENDER_MALE   = 0;
  const GENDER_FEMALE = 1;
  
  const MAX_LEVEL = 85;
  
  const RACE_HUMAN    = 1;
  const RACE_ORC      = 2;
  const RACE_DWARF    = 3;
  const RACE_NIGHTELF = 4;
  const RACE_UNDEAD   = 5;
  const RACE_TAUREN   = 6;
  const RACE_GNOME    = 7;
  const RACE_TROLL    = 8;
  const RACE_GOBLIN   = 9;
  const RACE_BLOODELF = 10;
  const RACE_DRAENEI  = 11;
  const RACE_WORGEN   = 22;
  
  const RARITY_POOR      = 0;
  const RARITY_COMMON    = 1;
  const RARITY_UNCOMMON  = 2;
  const RARITY_SUPERIOR  = 3;
  const RARITY_EPIC      = 4;
  const RARITY_LEGENDARY = 5;
  const RARITY_HEIRLOOM  = 7;
  
  const SKILL_NONE           = 0;
  const SKILL_ALCHEMY        = 171;
  const SKILL_BLACKSMITHING  = 164;
  const SKILL_ENCHANTING     = 333;
  const SKILL_ENGINEERING    = 202;
  const SKILL_HERBALISM      = 182;
  const SKILL_JEWELCRAFTING  = 755;
  const SKILL_LEATHERWORKING = 165;
  const SKILL_MINING         = 186;
  const SKILL_SKINNING       = 393;
  const SKILL_TAILORING      = 197;
  
  public static function IsPlayableRace($race, $class) {
    $is_playable = array(
      //                           1     2      3      4      5      6     7      8      9      10    11
      // class                     Warr  Pally  Hunter Rogue  Priest DK    Shaman Mage   Lock   --    Druid
      self::RACE_HUMAN    => array(TRUE, TRUE,  TRUE,  TRUE,  TRUE,  TRUE, FALSE, TRUE,  TRUE,  NULL, FALSE),
      self::RACE_ORC      => array(TRUE, FALSE, TRUE,  TRUE,  FALSE, TRUE, TRUE,  TRUE,  TRUE,  NULL, FALSE),
      self::RACE_DWARF    => array(TRUE, TRUE,  TRUE,  TRUE,  TRUE,  TRUE, TRUE,  TRUE,  FALSE, NULL, FALSE),
      self::RACE_NIGHTELF => array(TRUE, FALSE, TRUE,  TRUE,  TRUE,  TRUE, FALSE, TRUE,  FALSE, NULL, TRUE),
      self::RACE_UNDEAD   => array(TRUE, FALSE, TRUE,  TRUE,  TRUE,  TRUE, FALSE, TRUE,  TRUE,  NULL, FALSE),
      self::RACE_TAUREN   => array(TRUE, TRUE,  TRUE,  FALSE, TRUE,  TRUE, TRUE,  FALSE, FALSE, NULL, TRUE),
      self::RACE_GNOME    => array(TRUE, FALSE, FALSE, TRUE,  TRUE,  TRUE, FALSE, TRUE,  TRUE,  NULL, FALSE),
      self::RACE_TROLL    => array(TRUE, FALSE, TRUE,  TRUE,  TRUE,  TRUE, TRUE,  TRUE,  FALSE, NULL, TRUE),
      self::RACE_GOBLIN   => array(TRUE, FALSE, TRUE,  TRUE,  TRUE,  TRUE, TRUE,  TRUE,  TRUE,  NULL, FALSE),
      self::RACE_BLOODELF => array(TRUE, TRUE,  TRUE,  TRUE,  TRUE,  TRUE, FALSE, TRUE,  TRUE,  NULL, FALSE),
      self::RACE_DRAENEI  => array(TRUE, TRUE,  TRUE,  FALSE, TRUE,  TRUE, TRUE,  TRUE,  FALSE, NULL, FALSE),
      self::RACE_WORGEN   => array(TRUE, FALSE, TRUE,  TRUE,  TRUE,  TRUE, FALSE, TRUE,  TRUE,  NULL, TRUE),
    );
    
    // Remember, array indexes start at 0.
    return $is_playable[$race][$class-1];
  }
  
  public static function GetAllianceRaces() {
    return array(
      self::RACE_DRAENEI,
      self::RACE_DWARF,
      self::RACE_GNOME,
      self::RACE_HUMAN,
      self::RACE_NIGHTELF,
      self::RACE_WORGEN
    );
  }
  
  public static function GetHordeRaces() {
    return array(
      self::RACE_BLOODELF,
      self::RACE_GOBLIN,
      self::RACE_ORC,
      self::RACE_TAUREN,
      self::RACE_TROLL,
      self::RACE_UNDEAD
    );
  }
  
  public static function IsAlliance($race) {
    return in_array($race, self::GetAllianceRaces());
  }
  
  public static function IsHorde($race) {
    return in_array($race, self::GetHordeRaces());
  }
}
